const {
	Controller
} = require('uni-cloud-router')

module.exports = class SearchController extends Controller {
	async getCityList() {
		// let data = this.ctx.data
		// console.log(data);
		let res = await this.service.search.getCityList()
		return {
			code: 200,
			result: res.data
		}
	}
	
	async getNeareastCity() {
		let {
			userLocation
		} = this.ctx.data
		try{
			let res = await this.service.search.getNeareastCity({
				userLocation
			})
			return {
				code: 200,
				result: res
			}
		}catch(e){
			console.error(e)
			return {
				code: 500,
				result: e.message
			}
		}
	}
}
